package com.cskaoyan.handler;

import com.cskaoyan.bean.Account;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 创建日期: 2022/03/24 14:36
 *
 * @author ciggar
 */
public class MyResultSetHandler implements ResultSetHandler<List<Account>> {


    @Override
    public List<Account> handle(ResultSet rs) throws SQLException {

        List<Account> list = new ArrayList<Account>();

        while (rs.next()) {

            int id = rs.getInt("id");
            String name = rs.getString("name");
            String nickname = rs.getString("nickname");
            int money = rs.getInt("money");


            Account account = new Account();
            account.setId(id);
            account.setName(name);
            account.setMoney(money);
            account.setNickname(nickname);

            list.add(account);

        }


        return list;
    }
}
